package com.tracesystem.controller;


import com.tracesystem.commons.Result;
import com.tracesystem.controller.info.FileUploadInfo;
import com.tracesystem.service.IssueAttachService;
import com.tracesystem.util.OSSTemplate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.naming.Name;
import java.io.IOException;

/**
 * <p>
 *  附件信息处理接口
 * </p>
 *
 * @author Kevin Martin
 * @since 2022-03-23
 */
@Api(tags = "附件信息处理接口")
@RestController
@RequestMapping("/issueAttach")
public class IssueAttachController {

    @Autowired
    private IssueAttachService issueAttachService;
    /*
     * @Description:附件上传
     * @Author: JMOCOK
     * @param file: 上传文件
     * @return: com.tracesystem.commons.Result
     **/
    @ApiOperation("上传附件")
    @PostMapping("upload")
    public Result upload(MultipartFile file) throws IOException {

       return issueAttachService.uploadFile(file);
    }

    @ApiOperation("下载附件")
    @GetMapping("download")
    @ApiParam("附件id")
    public Result download(Integer attachId){
        return issueAttachService.downloadFile(attachId);
    }
}

